package com.ruoyi.firemen.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.firemen.domain.FmPFinfo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.firemen.service.IFmPhysicalFitnessinfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 基础体能考核Controller
 * 
 * @author zmc
 * @date 2024-09-25
 */
@RestController
@RequestMapping("/firemen/physicalFitness")
public class FmPhysicalFitnessinfoController extends BaseController
{
    @Autowired
    private IFmPhysicalFitnessinfoService fmPhysicalFitnessinfoService;

    /**
     * 查询基础体能考核列表
     */
    @PreAuthorize("@ss.hasPermi('firemen:physicalFitness:list')")
    @GetMapping("/list")
    public TableDataInfo list(FmPFinfo fmPhysicalFitnessinfo)
    {
        startPage();
        List<FmPFinfo> list = fmPhysicalFitnessinfoService.selectFmPhysicalFitnessinfoList(fmPhysicalFitnessinfo);
        return getDataTable(list);
    }

    /**
     * 导出基础体能考核列表
     */
    @PreAuthorize("@ss.hasPermi('firemen:physicalFitness:export')")
    @Log(title = "基础体能考核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FmPFinfo fmPhysicalFitnessinfo)
    {
        List<FmPFinfo> list = fmPhysicalFitnessinfoService.selectFmPhysicalFitnessinfoList(fmPhysicalFitnessinfo);
        ExcelUtil<FmPFinfo> util = new ExcelUtil<FmPFinfo>(FmPFinfo.class);
        util.exportExcel(response, list, "基础体能考核数据");
    }

    /**
     * 获取基础体能考核详细信息
     */
    @PreAuthorize("@ss.hasPermi('firemen:physicalFitness:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fmPhysicalFitnessinfoService.selectFmPhysicalFitnessinfoById(id));
    }

    /**
     * 新增基础体能考核
     */
    @PreAuthorize("@ss.hasPermi('firemen:physicalFitness:add')")
    @Log(title = "基础体能考核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FmPFinfo fmPhysicalFitnessinfo)
    {
        return toAjax(fmPhysicalFitnessinfoService.insertFmPhysicalFitnessinfo(fmPhysicalFitnessinfo));
    }
    /**
     * 新增基础体能考核
     */
    @PreAuthorize("@ss.hasPermi('firemen:physicalFitness:add')")
    @Log(title = "基础体能考核", businessType = BusinessType.INSERT)
    @PostMapping("/addApplied")
    public AjaxResult addApplied(@RequestBody FmPFinfo fmPhysicalFitnessinfo)
    {
        return toAjax(fmPhysicalFitnessinfoService.insertFmPhysicalFitnessinfoT(fmPhysicalFitnessinfo));
    }

    /**
     * 修改基础体能考核
     */
    @PreAuthorize("@ss.hasPermi('firemen:physicalFitness:edit')")
    @Log(title = "基础体能考核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FmPFinfo fmPhysicalFitnessinfo)
    {
        return toAjax(fmPhysicalFitnessinfoService.updateFmPhysicalFitnessinfo(fmPhysicalFitnessinfo));
    }
    /**
     * 修改应用体能考核
     */
    @PreAuthorize("@ss.hasPermi('firemen:physicalFitness:edit')")
    @Log(title = "基础体能考核", businessType = BusinessType.UPDATE)
    @PutMapping("/editApplied")
    public AjaxResult editApplied(@RequestBody FmPFinfo fmPhysicalFitnessinfo)
    {
        return toAjax(fmPhysicalFitnessinfoService.updateFmPhysicalFitnessinfoT(fmPhysicalFitnessinfo));
    }

    /**
     * 删除基础体能考核
     */
    @PreAuthorize("@ss.hasPermi('firemen:physicalFitness:remove')")
    @Log(title = "基础体能考核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fmPhysicalFitnessinfoService.deleteFmPhysicalFitnessinfoByIds(ids));
    }

    /**
     * 测试
     */
//    @PreAuthorize("@ss.hasPermi('firemen:physicalFitness:remove')")
//    @Log(title = "基础体能考核", businessType = BusinessType.DELETE)
    @GetMapping("/test")
    public AjaxResult test()
    {

        return success("ZMCCCC");
    }
}
